//
//  OtherView.swift
//  TLCLockDemo
//
//  Created by run on 2024/7/16.
//

import AlertToast
import Combine
import SwiftUI
import TLCLock

class OtherModel: SheetModel {
    let device: LockDevice

    init(device: LockDevice) {
        self.device = device
    }

    deinit {
        debugPrint("other model deinit")
    }
}

struct OtherView: View {
    let model: OtherModel
    

    var body: some View {
        VStack {
            Text(model.device.macAddress)
                .bold()
                .foregroundColor(.orange)
                .font(.headline)
                .padding(.horizontal, 20)
                .frame(maxWidth: .infinity, alignment: .center)
            
            YxrActionView(
                data: [
                    (0, "日志"),
                    (1, "声音设置"),
                    (2, "重置键"),
                    (3, "自动闭锁"),
                    (7, "防撬警报"),
                    (6, "门卡设置"),
                    (5, "过期提醒"),
                    (8, "门锁钥匙"),
                    (9, "黑名单"),
                    (10, "键盘锁定"),
                    (4, "恢复出厂设置"),
                    (11, "管理员密码"),
                ],
                itemBuilder: { value in
                    NavigationLink(
                        destination: {
                            switch value.0 {
                            case 0: ReadLogView(device: model.device)
                            case 1: VoiceView(device: model.device)
                            case 2: ResetBtnView(device: model.device)
                            case 3: AutoCloseLockView(device: model.device)
                            case 4: FactoryResetView(device: model.device)
                            case 5: RemindView(device: model.device)
                            case 6: CardSettingView(device: model.device)
                            case 7: AlarmView(device: model.device)
                            case 8: AllKeyView(device: model.device)
                            case 9: AddBlackListView(device: model.device)
                            case 10: KeyboardLockView(device: model.device)
                            case 11: AdminPwdView(device: model.device)
                            default: EmptyView()
                            }
                        },
                        label: {
                            Text(value.1)
                                .font(.system(size: 14))
                                .foregroundColor(.white)
                                .frame(minWidth: 40, maxWidth: .infinity, minHeight: 49, maxHeight: 49)
                                .background(Color.accentColor)
                                .cornerRadius(10)
                        }
                    )
                }
            ).padding(.horizontal, 10)
            
            LogView()
        }
        .yxrNavigationTitle("Other")
    }
}
